'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: queue_entity.py
* @Time: 2025/11/17
* @All Rights Reserve By Brtc
'''
from enum import Enum
from uuid import UUID

from pydantic import BaseModel, Field


class QueueEvent(str, Enum):
    """队列时间枚举类型"""
    LONG_TERM_MEMORY_RECALL = "long_term_memory_recall"
    AGENT_THOUGHT = "agent_thought"
    AGENT_MESSAGE = "agent_message"
    AGENT_ACTION = "agent_action"
    DATASET_RETRIEVAL = "dataset_retrieval"
    AGENT_END="agent_end"
    STOP = "stop"
    ERROR = "error"
    TIMEOUT = "timeout"
    PING = "ping"

class AgentQueueEvent(BaseModel):
    """智能体队列事件模型"""
    id:UUID # 事件id
    task_id:UUID # 任务id
    #事件的推理与观察
    event:QueueEvent
    thought:str = ""#推理内容
    observation:str = "" # 观察结果
    #工具相关内容
    tool:str = ""
    tool_input:dict = Field(default_factory=dict)
    #消息相关的数据
    messages:list[dict] = Field(default_factory=dict)
    messages_token_count:int = 0 #消息花费的tokens数量
    messages_unit_price:int = 0 #单价
    messages_price_unit:int = 0 #结算币种
    #答案相关的数据
    answer:str = ""#LLM生成的最终答案
    answer_token_count: int = 0  # 消息花费的tokens数量
    answer_unit_price: int = 0  # 单价
    answer_price_unit: int = 0  # 结算币种
    #统计
    total_token_count:int = 0  # 总token
    total_price:float = 0 # 总价格
    latency:float = 0  # 耗时

